import request from '@/utils/request.js';

// 登录接口
export function login(data) {
  return request({
    url: '/login',
    method: 'post',
    data
  });
  }
// 获取验证码 API 调用
export function fetchCaptchaAPI() {
  return request({
    url: `/common/verify?timestamp=${new Date().getTime()}`,
    method: 'get',
    responseType: 'blob' // 返回图片数据
  }).then(response => {
    console.log( 'fetchCaptchaAPI', response.data)
    return URL.createObjectURL(response.data)
  })
}

export function sendEmailCaptchaAPI(email) {
  return request({
    url: '/common/sendEmailCaptcha',
    method: 'get',
    params: { email }, // Sending email as a query parameter
    timeout: 120000
  });
}

//注册接口
export function register(data) {
  return request({
    url: '/register',
    method: 'post',
    data
  });
}
